<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .el-table .warning-row {
            background: oldlace;
        }

        .el-table .success-row {
            background: #f0f9eb;
        }

        .el-header, .el-footer {
            background-color: #B3C0D1;
            color: #333;
            text-align: center;
            line-height: 60px;
        }

        .el-aside {
            background-color: #D3DCE6;
            color: #333;
            text-align: center;
            line-height: calc(100%);
        }

        .el-main {
            background-color: #E9EEF3;
            color: #333;
            text-align: center;
            line-height: 160px;
            height: calc(100vh - 60px);
        }

        body > .el-container {
            margin-bottom: 100px;
        }

        .el-container:nth-child(5) .el-aside,
        .el-container:nth-child(6) .el-aside {
            line-height: 260px;
        }

        .el-container:nth-child(7) .el-aside {
            line-height: 320px;
        }

        .el-tree {
            display: inline-block;
            min-width: 100%;
            overflow: auto;
            width: 200px;
            height: calc(100%);
        }
    </style>
</head>
<body>
<div id="app">
    <el-tabs :tab-position="tabPosition" style="height: 200px;">
        <el-tab-pane label="三级目录">
            <template>
                <el-container>
                    <el-header style="display: flex; align-items: center; justify-content: flex-start;">
                        <el-image style="width: 60px; height: 60px" :src="url" :fit="fill"
                                  @click="drawer = true"></el-image>
                            <el-image style="width: 60px; height: 60px" :src="url2"  @click.native="startUser" :fit="fill"></el-image>
                    </el-header>
                    <el-container>
                        <el-aside width="200px">
                            <el-tree :data="treeData" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
                        </el-aside>
                        <el-container>
                            <el-main>
                                <el-table
                                        :data="productByCategoryId"
                                        style="width: 100%"
                                        :row-class-name="tableRowClassName">
                                    <el-table-column
                                            prop="id"
                                            label="ID"
                                            align="center">
                                    </el-table-column>
                                    <el-table-column
                                            prop="name"
                                            label="菜名"
                                            align="center">
                                    </el-table-column>
                                    <el-table-column
                                            prop="image"
                                            label="图片"
                                            align="center">
                                        <!--插入图片链接的代码-->
                                        <template slot-scope="scope">
                                            <img :src="scope.row.image" alt="" style="width: 100px;height: 100px">
                                        </template>

                                    </el-table-column>
                                    <el-table-column
                                            prop="detail"
                                            label="详情"
                                            align="center">
                                    </el-table-column>
                                    <el-table-column
                                            prop="categoryId"
                                            label="父类id"
                                            align="center">
                                    </el-table-column>
                                    <el-table-column
                                            prop="price"
                                            label="价格"
                                            align="center">
                                    </el-table-column>
                                    <el-table-column
                                            prop="stock"
                                            label="库存"
                                            align="center">
                                    </el-table-column>
                                    <el-table-column
                                            prop="status"
                                            label="状态"
                                            align="center">
                                    </el-table-column>
                                    <el-table-column
                                            prop="createTime"
                                            label="创建时间"
                                            align="center">
                                    </el-table-column>
                                    <el-table-column
                                            label="操作"
                                            align="center"
                                    >
                                        <el-row slot-scope="scope">
                                            <!--                                            <el-button type="primary" @click="addForCart(scope.$index,scope.row)">添加到购物车</el-button>-->
                                            <el-image style="width: 60px; height: 60px" :src="addUrl" :fit="fill"
                                                      @click="addForCart(scope.$index,scope.row)"></el-image>
                                        </el-row>
                                    </el-table-column>
                                </el-table>
                            </el-main>
                        </el-container>
                    </el-container>
                </el-container>
                <el-dialog
                        title="收获人信息"
                        :visible.sync="OrderMsgdialogTableVisible"
                        width="30%"
                        :before-close="handleClose">
                    <el-form ref="form" :model="receiver" label-width="80px">
                        <el-form-item label="收获人姓名">
                            <el-input v-model="receiver.receiverName"></el-input>
                        </el-form-item>
                        <el-form-item label="收获人电话">
                            <el-input v-model="receiver.receiverMobile"></el-input>
                        </el-form-item>
                        <el-form-item label="收获人地址">
                            <el-input v-model="receiver.receiverAddress"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <el-button type="primary" @click="createOrder">创建订单</el-button>
                            <el-button @click="OrderMsgdialogTableVisible = false">取消</el-button>
                        </el-form-item>
                    </el-form>

                </el-dialog>
                <el-drawer
                        title="购物车"
                        :visible.sync="drawer"
                        :direction="direction"
                        :before-close="handleClose"
                        size=60%
                >

                    <template>
                        <el-button type="primary" plain @click="OrderMsgdialogTableVisible = true">创建订单</el-button>


                        <el-table
                                :data="cartDto"
                                v-model="multipleSelection"
                                :selection-type="'multiple'"
                                style="width: 100%"
                                :row-class-name="tableRowClassName"
                                @selection-change="handleSelectionChange"
                        >
                            <el-table-column
                                    type="selection"
                                    width="55">
                            </el-table-column>
                            <el-table-column
                                    type="index"
                            >
                            </el-table-column>
                            <el-table-column
                                    prop="id"
                                    label="ID"
                                    align="center">
                            </el-table-column>
                            <el-table-column
                                    prop="productId"
                                    label="商品id"
                                    align="center">
                            </el-table-column>
                            <el-table-column
                                    prop="userId"
                                    label="用户id"
                                    align="center">
                            </el-table-column>
                            <el-table-column
                                    prop="quantity"
                                    label="数量"
                                    align="center">
                            </el-table-column>
                            <el-table-column
                                    prop="selected"
                                    label="选中状态"
                                    align="center">
                                <el-tooltip :content="'Switch value: ' + value" placement="top">
                                    <el-switch
                                            v-model="value"
                                            active-color="#13ce66"
                                            inactive-color="#ff4949"
                                            active-value="1"
                                            inactive-value="0">
                                    </el-switch>
                                </el-tooltip>
                            </el-table-column>
                            <el-table-column
                                    prop="price"
                                    label="单价"
                                    align="center">
                            </el-table-column>
                            <el-table-column
                                    prop="totalPrice"
                                    label="总价"
                                    align="center">
                            </el-table-column>
                            <el-table-column
                                    prop="productName"
                                    label="商品名称"
                                    align="center">
                            </el-table-column>
                            <el-table-column
                                    prop="productImage"
                                    label="图片"
                                    align="center">
                                <!--插入图片链接的代码-->
                                <template slot-scope="scope">
                                    <img :src="scope.row.productImage" alt="" style="width: 100px;height: 100px">
                                </template>
                            </el-table-column>
                        </el-table>
                        <!--                        <div class="block">-->
                        <!--                            <el-pagination-->
                        <!--                                    @size-change="handleSizeChange"-->
                        <!--                                    @current-change="handleCurrentChange"-->
                        <!--                                    :current-page="currentPage"-->
                        <!--                                    :page-sizes="[5, 10, 15, 20]"-->
                        <!--                                    :page-size="pageSize"-->
                        <!--                                    layout="total, sizes, prev, pager, next, jumper"-->
                        <!--                                    :total="totalPage"-->
                        <!--                                    align="center">-->
                        <!--                            </el-pagination>-->
                        <!--                        </div>-->
                    </template>

                </el-drawer>
            </template>
        </el-tab-pane>
        <el-tab-pane label="订单信息">
            <template>
                <el-dialog
                        title="详情"
                        :visible.sync="OrderItemDetail"
                        width="30%"
                        :before-close="handleClose">
                    <el-table
                            :data="orderItems"
                            style="width: 100%"
                            :row-class-name="tableRowClassName">
                        <el-table-column
                                prop="productName"
                                label="名称"
                                align="center">
                        </el-table-column>
                        <el-table-column
                                prop="image"
                                label="图片"
                                align="center">
                            <!--插入图片链接的代码-->
                            <template slot-scope="scope">
                                <img :src="scope.row.productImg" alt="" style="width: 100px;height: 100px">
                            </template>
                        </el-table-column>
                        <el-table-column
                                prop="unitPrice"
                                label="单价"
                                align="center">
                        </el-table-column>
                        <el-table-column
                                prop="quantity"
                                label="数量"
                                align="center">
                        </el-table-column>
                        <el-table-column
                                prop="totalPrice"
                                label="总价"
                                align="center">
                        </el-table-column>
                        <el-table-column
                                prop="createTime"
                                label="创建时间"
                                align="center">
                        </el-table-column>
                        <el-table-column
                                prop="updateTime"
                                label="更新时间"
                                align="center">
                        </el-table-column>
                    </el-table>
                </el-dialog>
                <el-table
                        :data="orderDto"
                        style="width: 100%"
                        :row-class-name="tableRowClassName">
                    <el-table-column
                            prop="smoothMallOrder.id"
                            label="ID"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="smoothMallOrder.orderNo"
                            label="订单号"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="smoothMallOrder.userId"
                            label="用户id"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="smoothMallOrder.totalPrice"
                            label="总价"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="smoothMallOrder.receiverName"
                            label="收货人姓名"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="smoothMallOrder.receiverMobile"
                            label="手机号"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="smoothMallOrder.receiverAddress"
                            label="收货地址"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="smoothMallOrder.orderStatus"
                            label="订单状态"
                            align="center">
                        <template #default="scope">
                            {{ scope.row.smoothMallOrder.orderStatus < 10 ? '用户已取消' :
                            scope.row.smoothMallOrder.orderStatus < 20 ? '未付款' : scope.row.smoothMallOrder.orderStatus <
                            30 ? '已付款' : scope.row.smoothMallOrder.orderStatus < 40 ? '已发货' : '交易完成' }}
                        </template>
                    </el-table-column>
                    <el-table-column
                            prop="smoothMallOrder.postage"
                            label="运费"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="smoothMallOrder.paymentType"
                            label="支付类型"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="smoothMallOrder.deliveryTime"
                            label="发货时间"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="smoothMallOrder.payTime"
                            label="支付时间"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="smoothMallOrder.endTime"
                            label="交易完成时间"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            label="操作"
                    >
                        <el-row slot-scope="scope">
                            <el-button type="primary" @click="orderDetail(scope.$index,scope.row)">订单详情</el-button>
                            <el-button type="danger" @click="orderDelete(scope.$index,scope.row)">取消订单</el-button>
                        </el-row>
                    </el-table-column>
                </el-table>
                <div class="block">
                    <el-pagination
                            @size-change="handleSizeChange"
                            @current-change="handleCurrentChange"
                            :current-page="currentPage"
                            :page-sizes="[5, 10, 15, 20]"
                            :page-size="pageSize"
                            layout="total, sizes, prev, pager, next, jumper"
                            :total="totalPage"
                            align="center">
                    </el-pagination>
                </div>
            </template>

        </el-tab-pane>
        <el-tab-pane label="食品管理" :disabled="productDisabled">
            <!--            这里是食品信息-->
            <template>
                <el-button type="primary" plain @click="addProductdialogVisible = true">新增</el-button>
                <el-image style="width: 60px; height: 60px" :src="url2"  @click.native="startServer" :fit="fill"></el-image>
                <el-dialog
                        title="编辑商品"
                        :visible.sync="addProductdialogVisible"
                        width="30%"
                >
                    <el-form ref="form" :model="addProduct" label-width="80px">
                        <el-form-item label="商品名称">
                            <el-input v-model="addProduct.name"></el-input>
                        </el-form-item>

                        <el-form-item label="商品详情">
                            <el-input v-model="addProduct.detail"></el-input>
                        </el-form-item>

                        <el-form-item label="父类id">
                            <div class="block">
                                <el-cascader
                                        v-model="selectedValue"
                                        :options="options"
                                        :props="{ checkStrictly: true }"
                                        @change="handleChange"
                                        clearable></el-cascader>
                            </div>
                        </el-form-item>

                        <el-form-item label="商品价格">
                            <el-input type="textarea" v-model="addProduct.price"></el-input>
                        </el-form-item>

                        <el-form-item label="商品库存">
                            <el-input type="textarea" v-model="addProduct.stock"></el-input>
                        </el-form-item>

                        <el-form-item label="商品状态">
                            <el-switch v-model="addProduct.status"
                                       active-value="1"
                                       inactive-value="0"
                            ></el-switch>
                        </el-form-item>

                        <el-form-item>
                            <el-button type="primary" @click="addProductTo">提交</el-button>
                            <el-button @click="addProductdialogVisible = false">取消</el-button>
                        </el-form-item>
                    </el-form>

                </el-dialog>
                ☞
                <el-table
                        :data="product"
                        style="width: 100%"
                        :row-class-name="tableRowClassName">
                    <!--                        <el-table-column-->
                    <!--                                prop="id"-->
                    <!--                                label="ID"-->
                    <!--                                align="center">-->
                    <!--                        </el-table-column>-->
                    <el-table-column
                            prop="name"
                            label="菜名"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="image"
                            label="图片"
                            align="center">
                        <!--插入图片链接的代码-->
                        <template slot-scope="scope">
                            <img :src="scope.row.image" alt="" style="width: 100px;height: 100px">
                        </template>

                    </el-table-column>
                    <el-table-column
                            prop="detail"
                            label="详情"
                            align="center">
                    </el-table-column>
                    <!--                        <el-table-column-->
                    <!--                                prop="categoryId"-->
                    <!--                                label="父类id"-->
                    <!--                                align="center">-->
                    <!--                        </el-table-column>-->
                    <el-table-column
                            prop="price"
                            label="价格"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="stock"
                            label="库存"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="status"
                            label="状态"
                            align="center">
                        <template #default="scope">
                            {{ scope.row.status == 1 ? '上架' : '下架' }}
                        </template>
                    </el-table-column>
                    <el-table-column
                            prop="createTime"
                            label="创建时间"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            label="操作"
                            align="center">
                        <el-row slot-scope="scope">
                            <el-button type="success" @click="editProduct(scope.$index, scope.row)" plain>编辑</el-button>
                            <el-button type="danger" @click="deleteProduct(scope.$index, scope.row)" plain>删除
                            </el-button>
                        </el-row>
                    </el-table-column>
                </el-table>
                <div class="block">
                    <el-pagination
                            @size-change="handleSizeChange"
                            @current-change="handleCurrentChange"
                            :current-page="currentPage"
                            :page-sizes="[5, 10, 15, 20]"
                            :page-size="pageSize"
                            layout="total, sizes, prev, pager, next, jumper"
                            :total="totalPage"
                            align="center">
                    </el-pagination>
                </div>
            </template>
        </el-tab-pane>
        <el-tab-pane label="分类管理" :disabled="categoryDisabled">
            <!--    这里是表格信息-->
            <template>
                <el-button type="primary" plain @click="dialogVisible = true">新增</el-button>
                <el-dialog
                        title="新增食品类别"
                        :visible.sync="dialogVisible"
                        width="30%"
                        :before-close="handleClose">
                    <el-form ref="form" :model="addCategory" label-width="80px">
                        <el-form-item label="名称">
                            <el-input v-model="addCategory.name"></el-input>
                        </el-form-item>
                        <el-form-item label="类别">
                            <el-input v-model="addCategory.type"></el-input>
                        </el-form-item>
                        <el-form-item label="父类id">
                            <el-input v-model="addCategory.parentId"></el-input>
                        </el-form-item>
                        <el-form-item label="排序序号">
                            <el-input v-model="addCategory.orderNum"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <el-button type="primary" @click="onSubmitCategory">新增类别</el-button>
                            <el-button @click="dialogVisible = false">取消</el-button>
                        </el-form-item>
                    </el-form>

                </el-dialog>
                <el-table
                        :data="category"
                        style="width: 100%"
                        :row-class-name="tableRowClassName">
                    <el-table-column
                            prop="id"
                            label="ID"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="name"
                            label="菜名"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="type"
                            label="类别"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="parentId"
                            label="父类id"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="orderNum"
                            label="排序序号"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            label="操作"
                            align="center">
                        <el-row slot-scope="scope">
                            <el-button type="success" @click="editCategory(scope.$index, scope.row)" plain>编辑
                            </el-button>
                            <el-button type="danger" @click="deleteCategory(scope.$index, scope.row)" plain>删除
                            </el-button>
                        </el-row>
                    </el-table-column>
                </el-table>

                <div class="block">
                    <el-pagination
                            @size-change="handleSizeChange"
                            @current-change="handleCurrentChange"
                            :current-page="currentPage"
                            :page-sizes="[5, 10, 15, 20]"
                            :page-size="pageSize"
                            layout="total, sizes, prev, pager, next, jumper"
                            :total="totalPage"
                            align="center">
                    </el-pagination>
                </div>
            </template>
            <!--                食品详细信息表格弹框-->
        </el-tab-pane>
        <el-tab-pane label="订单管理" :disabled="orderDisabled">
            <!--    这里是表格信息-->
            <template>
                <el-dialog
                        title="详情"
                        :visible.sync="adminOrderItemDetail"
                        width="30%"
                        :before-close="handleClose">
                    <el-table
                            :data="adminOrderItems"
                            style="width: 100%"
                            :row-class-name="tableRowClassName">
                        <el-table-column
                                prop="productName"
                                label="名称"
                                align="center">
                        </el-table-column>
                        <el-table-column
                                prop="image"
                                label="图片"
                                align="center">
                            <!--插入图片链接的代码-->
                            <template slot-scope="scope">
                                <img :src="scope.row.productImg" alt="" style="width: 100px;height: 100px">
                            </template>
                        </el-table-column>
                        <el-table-column
                                prop="unitPrice"
                                label="单价"
                                align="center">
                        </el-table-column>
                        <el-table-column
                                prop="quantity"
                                label="数量"
                                align="center">
                        </el-table-column>
                        <el-table-column
                                prop="totalPrice"
                                label="总价"
                                align="center">
                        </el-table-column>
                        <el-table-column
                                prop="createTime"
                                label="创建时间"
                                align="center">
                        </el-table-column>
                        <el-table-column
                                prop="updateTime"
                                label="更新时间"
                                align="center">
                        </el-table-column>
                    </el-table>
                </el-dialog>
                <el-table
                        :data="adminOrderDto"
                        style="width: 100%"
                        :row-class-name="tableRowClassName">
                    <el-table-column
                            prop="smoothMallOrder.id"
                            label="ID"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="smoothMallOrder.orderNo"
                            label="订单号"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="smoothMallOrder.userId"
                            label="用户id"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="smoothMallOrder.totalPrice"
                            label="总价"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="smoothMallOrder.receiverName"
                            label="收货人姓名"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="smoothMallOrder.receiverMobile"
                            label="手机号"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="smoothMallOrder.receiverAddress"
                            label="收货地址"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="smoothMallOrder.orderStatus"
                            label="订单状态"
                            align="center">
                        <template #default="scope">
                            {{ scope.row.smoothMallOrder.orderStatus < 10 ? '用户已取消' :
                            scope.row.smoothMallOrder.orderStatus < 20 ? '未付款' : scope.row.smoothMallOrder.orderStatus <
                            30 ? '已付款' : scope.row.smoothMallOrder.orderStatus < 40 ? '已发货' : '交易完成' }}
                        </template>
                    </el-table-column>
                    <el-table-column
                            prop="smoothMallOrder.postage"
                            label="运费"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="smoothMallOrder.paymentType"
                            label="支付类型"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="smoothMallOrder.deliveryTime"
                            label="发货时间"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="smoothMallOrder.payTime"
                            label="支付时间"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="smoothMallOrder.endTime"
                            label="交易完成时间"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            label="操作"
                    >
                        <el-row slot-scope="scope">
                            <el-popover
                                    placement="right"
                                    width="500"
                                    trigger="click">
                                <el-button type="primary" @click="adminOrderDetail(scope.$index,scope.row)">订单详情
                                </el-button>
                                <el-button type="danger" @click="orderDelete(scope.$index,scope.row)">删除订单</el-button>
                                <el-button type="warning" @click="orderDeliver(scope.$index,scope.row)">订单发货</el-button>
                                <el-button type="info" @click="orderFinish(scope.$index,scope.row)">订单完结</el-button>
                                <el-button slot="reference">操作订单</el-button>
                            </el-popover>
                        </el-row>
                    </el-table-column>
                </el-table>
                <div class="block">
                    <el-pagination
                            @size-change="handleSizeChange"
                            @current-change="handleCurrentChange"
                            :current-page="currentPage"
                            :page-sizes="[5, 10, 15, 20]"
                            :page-size="pageSize"
                            layout="total, sizes, prev, pager, next, jumper"
                            :total="totalPage"
                            align="center">
                    </el-pagination>
                </div>
            </template>
            <!--                食品详细信息表格弹框-->
        </el-tab-pane>
    </el-tabs>

</div>
</body>
<script src="js/vue.js">
</script>
<script src="element-ui/lib/index.js"></script>
<link rel="stylesheet" href="element-ui/lib/theme-chalk/index.css">
<script src="js/axios-0.18.0.js"></script>
<script>
    new Vue({
        el: "#app",
        mounted() {
            this.selectAllByPage();
            this.selectAllByPage2();
            this.selectCartDto();
            this.selectOrderDto();
            this.selectAdminOrderDto();
            this.getData();
            this.add();
        },
        methods: {
            tableRowClassName({row, rowIndex}) {
                if (rowIndex === 1) {
                    return 'warning-row';
                } else if (rowIndex === 3) {
                    return 'success-row';
                }
                return '';
            }
            ,
            handleSizeChange(val) {
                this.pageSize = val;
                this.selectAllByPage();
            },
            handleCurrentChange(val) {
                this.currentPage = val;
                this.selectAllByPage();
            },
            selectAllByPage() {
                var _this = this;
                axios({
                    method: "get",
                    url: "http://localhost:8066/admin/category/list/" + _this.currentPage + "/" + _this.pageSize,
                }).then(function (resp) {
                    if (resp.data.code == 0) {
                        _this.categoryDisabled = true;
                        if (resp.data.msg == '登录信息过期') {
                            _this.$message({
                                message: resp.data.msg,
                                type: 'error'
                            });
                        }
                    }
                    _this.category = resp.data.rows;
                    _this.totalPage = resp.data.totalCount;
                })
            },
            selectAllByPage2() {
                var _this = this;
                axios({
                    method: "get",
                    url: "http://localhost:8066/admin/product/list/" + _this.currentPage + "/" + _this.pageSize,
                }).then(function (resp) {
                    if (resp.data.code == 0) {
                        _this.productDisabled = true;
                        if (resp.data.msg == '登录信息过期') {
                            _this.$message({
                                message: resp.data.msg,
                                type: 'error'
                            });
                        }
                        // _this.$message({
                        //     message: "食品管理"+resp.data.msg,
                        //     type: 'error'
                        // });
                    }
                    _this.product = resp.data.rows;
                    _this.totalPage = resp.data.totalCount;
                })
            },
            // selectDetail(index,row){
            //     this.dialogTableVisible=true;
            //      var _this=this;
            //    axios({
            //        method: "post",
            //        url: "http://localhost:8080/PZHdemo01/ProductServlet",
            //        data:row.id
            //    }).then(function (resp) {
            //       _this.product=resp.data;
            //    })
            // },
            add() {
                var _this = this;
                axios({
                    method: "get",
                    url: "http://localhost:8066/category/list",
                }).then(function (resp) {
                    _this.categoryDto = resp.data;
                    _this.categoryDto.forEach(function (record) {
                        let children = []
                        if (Array.isArray(record.childCategory) && record.childCategory.length > 0) {
                            // 如果有子分类，只保留前两级别的选项
                            record.childCategory.forEach(function (child) {
                                children.push({
                                    label: child.name,
                                    value: child.id
                                })
                            })
                        }
                        _this.options.push({
                            label: record.name,
                            value: record.id,
                            children: children
                        });
                    });
                })
            },
            selectCartDto() {
                var _this = this;
                axios({
                    method: "get",
                    url: "http://localhost:8066/cart/list",
                }).then(function (resp) {
                    if (resp.data.code == 0) {
                        _this.categoryDisabled = true;
                        if (resp.data.msg == '登录信息过期') {
                            _this.$message({
                                message: resp.data.msg,
                                type: 'error'
                            });
                        }
                    }
                    _this.cartDto = resp.data;
                })
            },
            createOrder() {
                var _this = this;
                // const param = {
                //     receiverName:"极度愤怒",
                //     receiverMobile:"18366666666",
                //     receiverAddress:"731",
                // }
                for (var i = 0; i < this.multipleSelection.length; i++) {
                    this.selectIds[i] = this.multipleSelection[i].id;
                }
                _this.$message({
                    showClose: true,
                    message: this.multipleSelection,
                    type: 'success'
                });
                _this.$message({
                    showClose: true,
                    message: this.selectIds,
                    type: 'success'
                });
                axios({
                    method: "post",
                    url: "http://localhost:8066/order/create",
                    data: _this.receiver,
                }).then(function (resp) {
                    if (resp.data.code = 1) {
                        //判断成功后
                        //并且给出消息提示框
                        _this.OrderMsgdialogTableVisible = false;
                        _this.selectCartDto();
                        _this.selectOrderDto();
                        _this.$message({
                            showClose: true,
                            message: '恭喜你，创建成功！',
                            type: 'success'
                        });

                    } else {
                        _this.$message({
                            showClose: false,
                            message: '创建失败',
                            type: 'success'
                        });
                    }
                })
            },
            selectOrderDto() {
                var _this = this;
                axios({
                    method: "get",
                    url: "http://localhost:8066/order/list",
                }).then(function (resp) {

                    _this.orderDto = resp.data;
                    _this.orderItems = resp.data.orderItemVOList;
                })
            },
            selectAdminOrderDto() {
                var _this = this;
                axios({
                    method: "get",
                    url: "http://localhost:8066/admin/order/list",
                }).then(function (resp) {
                    if (resp.data.code == 0) {
                        _this.orderDisabled = true;
                        if (resp.data.msg == '登录信息过期') {
                            _this.$message({
                                message: resp.data.msg,
                                type: 'error'
                            });
                        }
                    }
                    _this.adminOrderDto = resp.data;
                    _this.adminOrderItems = resp.data.orderItemVOList;
                })
            }
            ,
            handleNodeClick(data) {
                var _this = this;
                const param = {
                    pageNum: this.currentPage,
                    pageSize: this.pageSize,
                    name: data.label,
                }
                test(param);

                function test(param) {
                    return axios({
                        method: "get",
                        url: "http://localhost:8066/product/mkdir/list",
                        params: param,
                        data: this.records
                    }).then(function (resp) {
                        // 设置表格数据
                        _this.productByCategoryId = resp.data.data.records;//{rows:[],totalCount:100}
                        // 设置总记录数
                        _this.totalCount = resp.data.data.total;
                    })
                }
            },
            onSubmitCategory() {
                var _this = this;
                axios({
                    method: "post",
                    url: "http://localhost:8066/admin/category/add",
                    data: _this.addCategory
                }).then(function (resp) {
                    // if (resp.code=="1"){
                    //判断提交成功后
                    //关闭新增品牌的页面
                    _this.dialogVisible = false;
                    //添加成功后再查询所有
                    _this.selectAllByPage();
                    //弹出添加成功的提示框
                    _this.$message({
                        message: '恭喜你，添加品牌成功！',
                        type: 'success'
                    });
                    // }
                })
            },
            editCategory(index, row) {
                var _this = this;
                axios({
                    method: "post",
                    url: "http://localhost:8066/admin/category/update",
                    data: row.id
                }).then(function (resp) {
                    if (resp.data = "yes") {
                        //判断修改成功后
                        //重新查询所有
                        _this.selectAllByPage();                            //并且给出消息提示框
                        _this.$message({
                            showClose: true,
                            message: '恭喜你，修改成功！',
                            type: 'success'
                        });
                    }
                })
            },
            deleteCategory(index, row) {
                var _this = this;
                axios({
                    method: "post",
                    url: "http://localhost:8066/admin/category/delete/" + row.id,
                }).then(function (resp) {
                    if (resp.data = "yes") {
                        //判断删除成功后
                        //重新查询所有
                        _this.selectAllByPage();
                        //并且给出消息提示框
                        _this.$message({
                            showClose: true,
                            message: '恭喜你，删除成功！',
                            type: 'success'
                        });
                    }
                })
            },
            addProductTo() {
                var _this = this;
                axios({
                    method: "post",
                    url: "http://localhost:8066/admin/product/add/",
                    data: _this.addProduct,
                }).then(function (resp) {
                    if (resp.data.code == 1) {
                        //判断成功后
                        //并且给出消息提示框
                        _this.$message({
                            showClose: true,
                            message: '恭喜你，添加成功！',
                            type: 'success'
                        });
                    }
                })
            },
            addForCart(index, row) {
                var _this = this;
                axios({
                    method: "post",
                    url: "http://localhost:8066/cart/add/" + row.id + "/" + 1,
                }).then(function (resp) {
                    if (resp.data.data == "yes") {
                        //判断成功后
                        //并且给出消息提示框
                        _this.$message({
                            showClose: true,
                            message: '恭喜你，添加成功！',
                            type: 'success'
                        });
                        _this.selectCartDto();
                    } else {
                        _this.$message({
                            showClose: false,
                            message: '库存不足',
                            type: 'error'
                        });
                    }
                })
            },
            orderDetail(index, row) {
                this.OrderItemDetail = true;
                this.orderItems = row.orderItemVOList;
            },
            adminOrderDetail(index, row) {
                this.adminOrderItemDetail = true;
                this.adminOrderItems = row.orderItemVOList;
            }
            ,
            orderDelete(index, row) {
                var _this = this;
                axios({
                    method: "post",
                    url: "http://localhost:8066/order/cancel/" + row.smoothMallOrder.orderNo,
                }).then(function (resp) {
                    if (resp.data.code = 1) {
                        //判断成功后
                        //并且给出消息提示框
                        _this.$message({
                            showClose: true,
                            message: '恭喜你，删除成功！',
                            type: 'success'
                        });
                        _this.selectOrderDto();
                    } else {
                        _this.$message({
                            showClose: false,
                            message: '取消失败',
                            type: 'error'
                        });
                    }
                })
            },
            orderDeliver(index, row) {
                var _this = this;
                axios({
                    method: "post",
                    url: "http://localhost:8066/admin/order/delivered/" + row.smoothMallOrder.orderNo,
                }).then(function (resp) {
                    if (resp.data.code = 1) {
                        //判断成功后
                        //并且给出消息提示框
                        _this.$message({
                            showClose: true,
                            message: '发货成功！',
                            type: 'success'
                        });
                        _this.selectOrderDto();
                        _this.selectAdminOrderDto()
                    } else {
                        _this.$message({
                            showClose: false,
                            message: '发货失败',
                            type: 'error'
                        });
                    }
                })
            },
            orderFinish(index, row) {
                var _this = this;
                axios({
                    method: "post",
                    url: "http://localhost:8066/admin/order/finished/" + row.smoothMallOrder.orderNo,
                }).then(function (resp) {
                    if (resp.data.code = 1) {
                        //判断成功后
                        //并且给出消息提示框
                        _this.$message({
                            showClose: true,
                            message: '完结成功！',
                            type: 'success'
                        });
                        _this.selectOrderDto();
                        _this.selectAdminOrderDto()
                    } else {
                        _this.$message({
                            showClose: false,
                            message: '完结失败',
                            type: 'error'
                        });
                    }
                })
            }
            ,
            startUser() {
                // 在这里执行跳转逻辑
                console.log('点击第二张图片，进入startUser方法');
                window.location.href="user.html";
            },
            startServer() {
                // 在这里执行跳转逻辑
                console.log('点击第二张图片，进入startUser方法');
                window.location.href="server.html";
            },
            getData() {
                axios.get('/category/treeList').then((response) => {
                    this.treeData = response.data;
                }).catch((error) => {
                    console.log(error);
                });
            }
        },//多选框
        // toggleSelection(rows) {
        //     if (rows) {
        //         rows.forEach(row => {
        //             this.$refs.multipleTable.toggleRowSelection(row);
        //         });
        //     } else {
        //         this.$refs.multipleTable.clearSelection();
        //     }
        // },
        handleSelectionChange(val) {
            this.multipleSelection = val;
        },
        //抽屉
        handleClose(done) {
            this.$confirm('确认关闭？')
                .then(_ => {
                    done();
                })
                .catch(_ => {
                });
        },
        data() {
            return {
                jumpUrl: "user.html",
                url: 'https://img0.baidu.com/it/u=4118902027,1605997138&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500',//图片连接
                url2: 'https://img1.baidu.com/it/u=3816957639,4143440156&fm=253&fmt=auto&app=138&f=JPEG?w=592&h=500',//客服图片连接
                addUrl: 'https://img1.baidu.com/it/u=1591480703,1603574652&fm=253&fmt=auto&app=138&f=PNG?w=500&h=500',
                treeData: [],
                defaultProps: {
                    children: 'children',
                    label: 'label'
                },
                addCategory: {
                    name: '',
                    type: '',
                    parentId: '',
                    orderNum: ''
                },
                addProduct: {
                    name: '',
                    image: '',
                    detail: '',
                    price: '',
                    stock: '',
                    status: '',
                    categoryId: ''
                },
                options: [{
                    value: "",
                    label: "",
                    children: []
                }],
                selectedValue: [],
                value: '1',
                category: [],
                categoryDto: [],
                cartDto: [],
                productByCategoryId: [],
                product: [],
                orderDto: [],
                adminOrderDto: [],
                orderItems: [],
                adminOrderItems: [],
                multipleSelection: [],//复选框选中的购物车清单
                selectIds: [],
                currentPage: 1,
                dialogVisible: false,//新增对话框是否显示
                totalPage: 0,
                pageSize: 20,
                tabPosition: 'top',
                dialogTableVisible: false,
                OrderMsgdialogTableVisible: false,
                addProductdialogVisible: false,
                OrderItemDetail: false,
                adminOrderItemDetail: false,
                productDisabled: false,
                categoryDisabled: false,
                orderDisabled: false,
                drawer: false,//抽屉属性
                direction: 'rtl',//抽屉属性
                receiver: {
                    receiverName: "极度愤怒",
                    receiverMobile: "18366666666",
                    receiverAddress: "731",
                }
            }
        }
    });

</script>
</html>